package cn.wolfcode.luowowo.article.service.impl;


import cn.wolfcode.luowowo.article.domain.SceneComments;
import cn.wolfcode.luowowo.article.mapper.SceneCommentsMapper;
import cn.wolfcode.luowowo.article.query.SceneCommentSQuery;
import cn.wolfcode.luowowo.article.service.ISceneCommentService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class SceneCommentServiceImpl implements ISceneCommentService {
    @Autowired
    private SceneCommentsMapper sceneCommentsMapper;

    @Override
    public void saveOrUpdate(SceneComments comment) {
        //景点的id
        if(comment.getSceneId()==null){
            sceneCommentsMapper.updateByPrimaryKey(comment);
        }else{
            sceneCommentsMapper.insert(comment);
        }
    }

    @Override
    public PageInfo<SceneComments> query(SceneCommentSQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        return new PageInfo(sceneCommentsMapper.query(qo));
    }

    @Override
    public int selectReply(Long sceneId) {
        return sceneCommentsMapper.selectReplyNum(sceneId);
    }
}
